﻿/*              Copyright(c) 2008 Dave Sexton              *
 * http://www.codeplex.com/DocProject                      *
 * http://www.codeplex.com/DocProject/Project/License.aspx *
 ***********************************************************/
using System;
using System.Collections.Generic;
using System.Text;

namespace DaveSexton.DocToMaml
{
	internal sealed class RuleEqualityComparer : EqualityComparer<IRule>
	{
		#region Public Properties
		public static new readonly RuleEqualityComparer Default = new RuleEqualityComparer();
		#endregion

		#region Constructors
		/// <summary>
		/// Constructs a new instance of the <see cref="RuleEqualityComparer" /> class.
		/// </summary>
		private RuleEqualityComparer()
		{
		}
		#endregion

		#region Methods
		public override bool Equals(IRule x, IRule y)
		{
			return x.MatchKind == y.MatchKind
				&& string.Equals(x.Match, y.Match, StringComparison.OrdinalIgnoreCase);
		}

		public override int GetHashCode(IRule obj)
		{
			return obj.MatchKind.GetHashCode() ^ obj.Match.GetHashCode();
		}
		#endregion
	}
}
